﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;
using T.FAS.Runtime.Base.Service;
using T.FAS.Runtime.Base.SGSPI;
using T.ServiceComponent.Kernel.Service;

namespace T.FAS.Runtime.Base.SGPlugin
{
    [SGService]
    public class FasMaskSGService : IFasMaskSGService
    {
        readonly FasMaskService _service = FasMaskService.GetInstance();
        /// <summary>
        /// 获取掩码结果
        /// </summary>
        /// <returns></returns>
        public string GetMaskData(string pattern, string replacement, string input)
        {
            if (string.IsNullOrEmpty(pattern)) throw new ArgumentNullException(nameof(pattern));
            if (string.IsNullOrEmpty(input)) throw new ArgumentNullException(nameof(input));

            bool flag = _service.TryGetMaskData(pattern, replacement, input, out string result);
            if (flag)
            {
                return result;
            }
            else
            {
                return "-1";
            }
        } 
    }
}
